package com.chixing.entity;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Document(collection = "comment")
public class CommentDoc {

    @Id
    private String id;

    @Field("movie_id")
    private Integer movieId; // 对应电影ID

    @Field("user_id")
    private Integer userId; // 评论用户ID

    @Field("user_name")
    private String userName; // 评论用户名（冗余存储，避免关联查询）

    private String content; // 评论内容

    @Field("parent_id")
    private String parentId; // 父评论ID，为空表示一级评论

    @Field("reply_to_user_id")
    private Integer replyToUserId; // 被回复的用户ID

    @Field("reply_to_user_name")
    private String replyToUserName; // 被回复的用户名

    private Integer likes = 0; // 点赞数

    @Field("create_time")
    private LocalDateTime createTime = LocalDateTime.now(); // 创建时间

    @Field("update_time")
    private LocalDateTime updateTime = LocalDateTime.now(); // 更新时间

    private List<CommentDoc> children = new ArrayList<>(); // 子评论列表

    // 构造函数
    public CommentDoc() {}

    // Getters and Setters
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Integer getMovieId() {
        return movieId;
    }

    public void setMovieId(Integer movieId) {
        this.movieId = movieId;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public Integer getReplyToUserId() {
        return replyToUserId;
    }

    public void setReplyToUserId(Integer replyToUserId) {
        this.replyToUserId = replyToUserId;
    }

    public String getReplyToUserName() {
        return replyToUserName;
    }

    public void setReplyToUserName(String replyToUserName) {
        this.replyToUserName = replyToUserName;
    }

    public Integer getLikes() {
        return likes;
    }

    public void setLikes(Integer likes) {
        this.likes = likes;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public List<CommentDoc> getChildren() {
        return children;
    }

    public void setChildren(List<CommentDoc> children) {
        this.children = children;
    }
}

